#include "qtquick2applicationviewer.h"
#include "smartingeegclientagent.h"
#include "plot.h"
#include "qcustomplot.h"
#include "signalprocessing/signalprocessing.h"
#include "signalprocessing/sampler/decimator.h"
#include "signalprocessing/splitter.h"
#include "signalprocessing/smartingeegrecord.h"
#include "signalprocessing/filter/butterfilter.h"
#include "signalprocessing/filter/notchfilter.h"
#include "signalprocessing/smartingimpedancemeter.h"
#include "signalprocessing/filter/butterfilter.h"

#include <QApplication>
#include <QQmlContext>
#include <QtQml>
#include <QQuickItem>
#include <QQuickView>
#include <QNetworkInterface>
#include <QNetworkSession>
#include <QNetworkConfiguration>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    SignalConnection::registerTypes("SignalConnection");
    Decimator::registerTypes("Decimator");
    SmartingEEGClientAgent::registerTypes("SmartingEEGClientAgent");
    SmartingEEGRecord::registerTypes("SmartingEEGRecord");
    Splitter::registerTypes("Splitter");
    SmartingImpedanceMeter::registerTypes("SmartingImpedanceMeter");

    qmlRegisterType<ButterFilter>("ButterFilter", 1, 0, "ButterFilter");
    qmlRegisterType<NotchFilter>("NotchFilter", 1, 0, "NotchFilter");
    qmlRegisterType<Plot>("CustomPlot", 1, 0, "Plot");

    QNetworkConfigurationManager confMgr;
    QList<QNetworkConfiguration> wlanLst = confMgr.allConfigurations();
    qDebug() << "*****************************";
    for(int i = 0; i < wlanLst.count(); ++i)
    {
        QNetworkConfiguration wlanConf = wlanLst.at(i);
        QNetworkSession *wlanSession = new QNetworkSession(wlanConf);

        qDebug() << wlanSession->interface().name();
        wlanSession->stop();

        qDebug() << wlanSession->state();
        qDebug() << wlanSession->errorString();
        QThread::sleep(1);
        qDebug() << wlanSession->state();

        delete wlanSession;
    }


    QtQuick2ApplicationViewer viewer;
    viewer.setMainQmlFile(QStringLiteral("qml/SmartingEEGClient/MainPage.qml"));
    viewer.show();
    return app.exec();
}
